function uiBtn(value, row, index) {
    return '<button class="btn btn-primary  btn-sm" type="button">上传</button>';
}

window.tbSlavePickerUploadBeforeSend = function (object, data, headers) {
    var selected = $("#easyui-datagrid-left").datagrid("getSelected");
    if (typeof(selected.id) != 'undefined') {
        data.folderId = selected.id;
    }
    return true;
}

window.tbSlavePickerUploadComplete = function (file) {
    $("#easyui-datagrid-right").datagrid("load");
}

$(function () {
    $(".jr-grid-upload").click(function (e) {
        if (typeof(e.clientX) == 'undefined') {
            //查询是否有选中
            var selected = $("#easyui-datagrid-left").datagrid("getSelected");
            if (null != selected) {
                return true;
            } else {
                alert("请选择要上传的文件夹！");
            }
        }
        return false;
    });
    $(".jr-edit-choose").unbind("click");
    $(".jr-edit-choose").click(function () {
        openerSet();
    });
});

var firstLoad = true;

function leftOnLoadSuccess() {
    $("#easyui-datagrid-left").datagrid("selectRow", 0);
}
function rightOnDblClickRow() {
    openerSet();
}

function leftOnSelect(rowIndex, rowData) {
    if (!firstLoad) {
        var $grid = $("#easyui-datagrid-right");
        if (typeof(rowData.id) != 'undefined') {
            var param = mergeGridParam([$grid.datagrid("options").queryParams, {"search.eq.folderId": rowData.id}]);
            $grid.datagrid("load", param);
        } else {
            var param = mergeGridParam([$grid.datagrid("options").queryParams, {"search.eq.folderId": "null"}]);
            $grid.datagrid("load", param);
        }
    }
    firstLoad = false;
}